<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>测试</title>
    <link rel="stylesheet" href="/shop/css/reset.css">
    <link rel="stylesheet" href="/shop/css/main.css">
    <script type="text/javascript">
        SITEURL = '{:C("SITE_URL")}';
    </script>
</head>
<body>
<div class="zhi-btn-wp" id="ttt">

</div>


</body>
<script type="text/javascript" src="/shop/js/jquery.min.js"></script>
<script type="text/javascript" src="/shop/js/wechat.js"></script>
<script type="text/javascript">

    $(function () {
        $.ajax({
            type: 'get',
            url: apiUrl + 'wechat/shop/getShareData',
            async: false,
            cache: false,
//            data: {code: code},
            dataType: 'json',
            success: function (result) {

                wx.config({
                    debug: false,
                    appId: result.data.sign.appId,
                    timestamp: result.data.sign.timestamp,
                    nonceStr: result.data.sign.nonceStr,
                    signature: result.data.sign.signature,
                    jsApiList: [
                        'checkJsApi',
                        'onMenuShareTimeline',
                        'onMenuShareAppMessage'
                    ]
                });
                wx.ready(function () {
                    wx.checkJsApi({
                        jsApiList: [
                            'onMenuShareTimeline',
                            'onMenuShareAppMessage'
                        ],
                        success: function (res) {
                            // alert(JSON.stringify(res));
                        }
                    });

                    wx.onMenuShareAppMessage({
                        title: result.data.share.title,
                        desc: result.data.share.desc,
                        link: result.data.share.url,
                        imgUrl: result.data.share.logo,
                        trigger: function (res) {
                            //alert('点击发送给朋友');
                        },
                        success: function (res) {
                            // alert('已分享');
                        },
                        cancel: function (res) {
                            // alert('已取消');
                        },
                        fail: function (res) {
                            // alert(JSON.stringify(res));
                        }
                    });

                    wx.onMenuShareTimeline({
                        title: result.data.share.title,
                        link: result.data.share.url,
                        imgUrl: result.data.share.logo,
                        trigger: function (res) {
                            // alert('点击分享到朋友圈');
                        },
                        success: function (res) {
                            // alert('已分享');
                        },
                        cancel: function (res) {
                            // alert('已取消');
                        },
                        fail: function (res) {
                            // alert(JSON.stringify(res));
                        }
                    });
                });



            }
        });
    });


</script>
</html>